<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class VADefaultRecordationAndTransferTaxFactory{

    /**
     * what I sent you in my spreadsheet is the default for VA - in that the seller does not pay much in the way of tax in virginia.
     * only a deed grantor (seller) tax -
     *
     *
     * @param propertyTransferTax
     * @param countyPropertyTransferTax
     * @param recordationTax
     * @param extraBuyerRecordationTax
     *@param payerSpecialCase  @return
     */
    public function createSplitRecordationAndTransferTaxes($propertyTransferTax,
                                                                                $countyPropertyTransferTax,
                                                                                $recordationTax,
                                                                                $extraBuyerRecordationTax,
                                                                                $fees,
                                                                                $payerSpecialCase) {

        $zeroRecordationTax = null;
        if ($recordationTax != null) {
            $zeroRecordationTax = new RecordationTax($recordationTax->getName(), $extraBuyerRecordationTax);
        } else {
            $zeroRecordationTax = null;
        }

        $zeroPropertyTransferTax = null;
        if ($propertyTransferTax != null) {
            $zeroPropertyTransferTax = new StatePropertyTransferTax($propertyTransferTax->getName(), 0.0);
        } else {
            $zeroPropertyTransferTax = null;
        }

        $zeroCountyPropertyTransferTax;
        if ($countyPropertyTransferTax != null) {
            $zeroCountyPropertyTransferTax = new CountyPropertyTransferTax($countyPropertyTransferTax->getName(), 0.0);
        } else {
            $zeroCountyPropertyTransferTax = null;
        }

        $zeroFees = FeeHelper::getCloneWithZeroValue($fees);

        $recordationAndTransferTaxes = array();

        if ($payerSpecialCase == null) {
            $recordationAndTransferTaxes[] = new RecordationAndTransferTaxes(
                    $propertyTransferTax, $countyPropertyTransferTax, $zeroRecordationTax,
                    $fees,
                    EPayer::Buyer);

            $recordationAndTransferTaxes[] = new RecordationAndTransferTaxes(
                    $zeroPropertyTransferTax, $zeroCountyPropertyTransferTax, $recordationTax,
                    $zeroFees,
                    EPayer::Seller);
        } else if ($payerSpecialCase == EPayerSpecialCase::SellerMustPayStateTax) {
            $recordationAndTransferTaxes[] = new RecordationAndTransferTaxes(
                    $zeroPropertyTransferTax, $countyPropertyTransferTax, $zeroRecordationTax,
                    $fees,
                    EPayer::Buyer);

            $recordationAndTransferTaxes[] = new RecordationAndTransferTaxes(
                    $propertyTransferTax, $zeroCountyPropertyTransferTax, $recordationTax,
                    $zeroFees,
                    EPayer::Seller);
        }

        return $recordationAndTransferTaxes;
    }
}
?>
